﻿@using Classified.Domain.Entities
@model User

@{
    ViewBag.Title = "Create";
    Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";
}



<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>


<h1>Create new <small> User</small></h1>

@using (Html.BeginForm("Create", "User", FormMethod.Post))
{
    @Html.ValidationSummary(true)

    
      <fieldset>
      

          <div class="clearfix">
        
              @Html.LabelFor(model => model.FirstName)
              <div class="input">
                  @Html.EditorFor(model => model.FirstName)
                  @Html.ValidationMessageFor(model => model.FirstName)
              </div>
          </div>
          
          <div class="clearfix">
               @Html.LabelFor(model => model.LastName)
              <div class="input">
                    @Html.EditorFor(model => model.LastName)
            @Html.ValidationMessageFor(model => model.LastName)
              </div>
          </div>
          <div class="clearfix">
               @Html.LabelFor(model => model.UserName)
              <div class="input">
                    @Html.EditorFor(model => model.UserName)
            @Html.ValidationMessageFor(model => model.UserName)
              </div>
          </div>
          <div class="clearfix">
               @Html.LabelFor(model => model.Email)
              <div class="input">
                   @Html.EditorFor(model => model.Email)
            @Html.ValidationMessageFor(model => model.Email)
              </div>
          </div>
          <div class="clearfix">
               @Html.LabelFor(model => model.Password)
              <div class="input">
            @Html.PasswordFor(model => model.Password)
            @Html.ValidationMessageFor(model => model.Password)
              </div>
          </div>
          <div class="clearfix">
             Roles
               
              <div class="input chzn-select">
                  @{
                    List<Role> roles =  ViewBag.RolesList;
                  }
                  @foreach(var role in roles)
                  {
                      if (Model.Roles!=null &&Model.Roles.Any(x => x.RoleName == role.RoleName))
                      {
                          <text>
                          <input type="checkbox" name="role" value="@role.RoleName" checked="checked" /> @role.RoleName
                         </text>
                      }
                      else
                      {
                           <text>
                          <input type="checkbox" name="role" value="@role.RoleName" /> @role.RoleName
                         </text>
  
                      }

                  }
                 
              </div>
          </div>
           <div class="clearfix">
               @Html.LabelFor(model => model.IsActive)
              <div class="input">
            @Html.EditorFor(model => model.IsActive)
            @Html.ValidationMessageFor(model => model.IsActive)
              </div>
          </div>
       <div class="actions">
            <input type="submit" class="btn primary" value="Save" />
            
			@Html.ActionLink("Back to List", "List", null, new { @class = "btn" })
        </div>

      </fieldset>
   
}
